
<script>
import { h } from 'vue'
export default {
  name: 'XtxBread',
  //   render用于渲染虚拟dom
  render ({ $slots }) {
    const slot = $slots.default()
    // slot等于传进来的3个虚拟dom  首页 居家 二级分类
    // 遍历在后面加个i标签
    console.log(slot)
    const arr = []
    slot.forEach((item, index) => {
      arr.push(item)
      if (index < slot.length - 1) {
        arr.push(h('i', { class: 'iconfont icon-angle-right' }))
      }
    })
    // <i class="iconfont icon-angle-right"></i>
    // h函数创建虚拟dom ('组件名','属性','内容')
    // const divVNode = h('div', { class: 'xtx-bread' }, slot)
    const divVNode = h('div', { class: 'xtx-bread' }, arr)
    return divVNode
  }
}
</script>

<style  lang='less'>
.xtx-bread{
  display: flex;
  padding: 25px 10px;
  &-item {
    a {
      color: #666;
      transition: all .4s;
      &:hover {
        color: @xtxColor;
      }

    }
  &:last-child{
      i{
          display: none;
      }
  }
  }
  i {
    font-size: 12px;
    margin-left: 5px;
    margin-right: 5px;
    line-height: 22px;
  }
}
</style>
